$(function(){
    //设置一个全局的变量，存储验证码
    var code;
    function createCode(){
        //首先默认code为空字符串
        code = '';
        //设置验证码长度
        var codeLength = 4;
        var codeV = document.getElementById('code');
        //设置随机字符
        var random =[0,1,2,3,4,5,6,7,8,9,'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'];
        //循环codeLength 设置的4就是循环4次
        for(var i = 0; i < codeLength; i++){
            //设置随机数范围,这设置为0 ~ 63
                var index = Math.floor(Math.random()*62);
                //字符串拼接 将每次随机的字符 进行拼接
                code += random[index]; 
        }
        //将拼接好的字符串赋值给展示的span
        codeV.innerText = code;
    }
    //设置此处的原因是每次进入界面展示一个随机的验证码，不设置则为空
    // window.onload = function (){
        createCode();
    // }
    // 点击换一张展示一个新的验证码
    $('.logBbut').click(
        function(){
            createCode();
        }
    )
})